<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="/assets/css/admin.css">
<link rel="stylesheet" href="/assets/css/bootstrap.min.css">
<link rel="stylesheet" href="/assets/css/iconfont/iconfont.css">
<title>人车人</title><link rel="icon" href="/assets/img/titleico.ico" type="image/x-icon">
<script src="/assets/js/jquery-3.1.1.min.js"></script>
<script src="/assets/js/echarts.min.js"></script>
<style>
:root {
	overflow-x: auto;
}

body {
	background-color: #f5f5f5;
	padding: 0;
	overflow: visible;
	width: 100%;
}

.headbody {
	padding-top: 20px;
	background-color: #fff;
}

.contariner {
	position: relative;
	overflow: hidden;
}

.contariner .content {
	padding: 10px;
	margin-top: 13px;
	margin-bottom: 30px;
	background-color: #fff;
	margin-left: 16%;
	-webkit-box-shadow: 0px 0px 20px rgba(0, 0, 0, .05);
	box-shadow: 0px 0px 20px rgba(0, 0, 0, .05);
}

.contariner .content .chartbox {
	padding: 10px;
	border: 1px solid #dadada;
	border-radius: 3px;
	margin-bottom: 15px;
}

.contariner .content .chartbox:last-child {
	margin-bottom: 0;
}

.contariner .content .fkchart {
	height: 350px;
}

.contariner .content .pies {
	overflow: hidden;
}

.contariner .content .pies .pie {
	height: 320px;
	float: left;
}

.contariner .content .ywchart {
	height: 450px;
}

.contariner .content .search {
	margin-bottom: 10px;
	overflow: hidden;
}

.contariner .content .search .form-control {
	width: 125px;
	display: inline-block;
	float: left;
	margin-right: 10px;
}

.contariner .navbox {
	position: absolute;
	width: 15%;
	top: 60px;
	left: 0;
	bottom: 0;
	background-color: #fff;
	-webkit-box-shadow: 1px 0px 10px rgba(0, 0, 0, .05);
	box-shadow: 1px 0px 10px rgba(0, 0, 0, .05);
	z-index: 1;
	padding: 0;
}

.contariner .navbox .searchbox {
	padding: 20px;
	margin-bottom: 20px;
	border-bottom: 1px solid #eee;
	position: relative;
}

.contariner .navbox .searchbox i {
	position: absolute;
	top: 28px;
	right: 28px;
	cursor: pointer;
}

.contariner .navbox ul.nav li a {
	display: block;
	padding: 8px 15px;
	color: #09f;
}

.contariner .navbox ul.nav li a i {
	margin-right: 10px;
}

.contariner .navbox ul.nav li.active a {
	color: #fff;
	background-color: #09f;
}

/*@media screen and (max-width: 1360px) {
	.contariner .navbox {
		display: none;
	}
	.contariner .content {
		width: 95%;
		margin: 30px auto;
		float: none;
	}
}*/

@media screen and (max-width: 850px) {
	.contariner .content .pies .pie {
		float: none;
		width: 95%;
		margin: 0 auto 20px;
	}
}
</style>
</head>
<body>
	<div class="contariner" id="contariner">
		#@adminHeader()
		<div class="navbox col-md-3">
			<div class="searchbox">
				<form action="#" method="get">
					<input type="text" name="search" placeholder="搜索"
						class="form-control" /> <i class="iconfont" id="searchbtn">&#xe664;</i>
				</form>
			</div>
			<ul class="nav">
				<li class="#(tableType=='statistic'?'active':'')"><a
					href="/admin/dataStatistic"> <i class="iconfont">&#xe649;</i>
						车抵贷
				</a></li>
				<li class="#(tableType=='query'?'active':'')"><a
					href="/admin/dataQuery"> <i class="iconfont">&#xe617;</i> 数据查询
				</a></li>
			</ul>
		</div>
		<div class="content col-md-10">
			<div class="search">
				<select id="province" class="form-control">
					<option value="">选择省份</option>
				</select> <select id="city" class="form-control">
					<option value="">选择城市</option>
				</select> <select id="year" class="form-control">
					<option value="">选择年份</option>
				</select> <select id="month" class="form-control">
					<option value="">选择月份</option>
					<option value="01">1月</option>
					<option value="02">2月</option>
					<option value="03">3月</option>
					<option value="04">4月</option>
					<option value="05">5月</option>
					<option value="06">6月</option>
					<option value="07">7月</option>
					<option value="08">8月</option>
					<option value="09">9月</option>
					<option value="10">10月</option>
					<option value="11">11月</option>
					<option value="12">12月</option>
				</select>
			</div>
			<div class="chartbox fkchart change" id="fkchart"
				data-filter="progress=4#progress<6" data-now="0" data-today="0"
				data-all="0"></div>
			<div class="chartbox pies">
				<div class="pie col-md-6 itemtypechart change" id="itemTypePie"
					data-filter=""></div>
<!-- 				<div class="pie col-md-4 paymentchart change" id="paymentPie" -->
<!-- 					data-filter=""></div> -->
				<div class="pie col-md-6 orderchar change" id="orderPie"
					data-filter="(progress=4 or progress=6)"></div>
			</div>
			<div class="chartbox ywchart change" id="ywchart" data-filter=""></div>
		</div>
	</div>
	
	<script>
		$(function(){
			console.log(decodeURI(window.location.search))
			//搜索
			$("#searchbtn").click(function(){
				var input = $(this).siblings("input");
				if(input.val() != ""){
					$(this).parent().submit();
				}else{
					input.focus();
				}
			})
			
			var contariner = $("#contariner"),//页面容器
				date = new Date(),
				year = date.getFullYear(),
				yearSel = "",
				provinceDom = $("#province"),
				cityDom = $("#city"),
				provinceArr = [],
				cityArr = [];
				
			for(var i = 2016;i <= year;i++){
				yearSel += "<option value='"+ i +"'>"+ i +"年</option>";
			}
			$("#year").append(yearSel)
			
			//获取省市
			$.getJSON("/statis/getFilterAttrs",function(data){
				provinceArr = data.pro;
				cityArr = data.city;
				var provinceSel = "";
				for(var i = 0;i < provinceArr.length;i++){
					provinceSel += "<option value='"+ i +"'>"+ provinceArr[i] +"</option>";
				}
				provinceDom.append(provinceSel);
			})
			
			var	monthArr = ["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],
				date = new Date(),
				fkChartBox = $("#fkchart")[0],//放款量折线图
				fkChart = echarts.init(fkChartBox),
				itemTypeCharBox = $("#itemTypePie")[0],//产品类型单子统计
				itemTypeChar = echarts.init(itemTypeCharBox),
				orderCharBox = $("#orderPie")[0],//通过、放弃单量统计
				orderChar = echarts.init(orderCharBox),
				ywChartBox = $("#ywchart")[0],//业务数据统计
				ywChar = echarts.init(ywChartBox);
				//paymentChartBox = $("#paymentPie")[0],//还款
				//paymentChar = echarts.init(paymentChartBox);
			
			//还款统计",{tab:"bargain_loan",param:"loanAmount,itemType",datePara:"date",
			/*$.getJSON("/statis/getStatisByDate",{tab:"bargain_loan",param:"repayDateOfDay",datePara:"date"},function(data){
				console.log(data)
			})*/
			/*$.getJSON("/statis/getStatis",{tab:"bargain_loan",param:"repayDateOfDay"},function(data){
				var repayDateOfDays = [],
					repayDateTitle = ["每月5号","每月15号","每月25号"];
				
				if(data.code == 1){
					repayDateOfDays = data.repayDateOfDay;
					for(var i = 0;i < repayDateOfDays.length;i++){
						if(repayDateOfDays[i].name == 5){
							repayDateOfDays[i].name = "每月5号";
						}else if(repayDateOfDays[i].name == 15){
							repayDateOfDays[i].name = "每月15号";
						}else if(repayDateOfDays[i].name == 25){
							repayDateOfDays[i].name = "每月25号";
						}
					}
					paymentChar.setOption({
						title : {
					        text: '还款人数',
					        x:'40%',
					        textStyle: {
					       		fontWeight: 'normal',
					       		color: '#666'
					        }
					    },
					    toolbox: {
					        show : true,
					        feature : {
					            dataView : {show: true, readOnly: false},
					            saveAsImage : {show: true}
					        }
					    },
					    color:["#337ab7","#5cb85c","#5bc0de","#f0ad4e"],
					    tooltip : {
					        trigger: 'item',
					        formatter: "{a} <br/>{b} : {c} ({d}%)"
					    },
					    legend: {
					        orient: 'vertical',
					        left: 'left',
					        data: repayDateTitle
					    },
					    series : [
					        {
					            name: '还款人数',
					            type: 'pie',
					            radius : '55%',
					            center: ['50%', '60%'],
					            data:repayDateOfDays,
					            itemStyle: {
					            	normal:{ 
		                                label:{ 
		                                   show: true, 
		                                   formatter: '{b} : {c} ({d}%)' 
		                                }, 
		                                labelLine :{show:true}
		                            },
					                emphasis: {
					                    shadowBlur: 10,
					                    shadowOffsetX: 0,
					                    shadowColor: 'rgba(0, 0, 0, 0.5)'
					                }
					            }
					        }
					    ]
					})
				}
			})*/
			
			//总金额查询
			$.getJSON("/statis/getStatis",{tab:"bargain_loan",param:"loanAmount"},function(data){
				var $fkChartBox = $(fkChartBox),
					nowMoney = $fkChartBox.data("now"),
					todayMoney = $fkChartBox.data("today"),
					allMoney = data.loanAmount.sum;
				$(fkChartBox).data("all",allMoney);
				fkChart.setOption({
					title: {
				        text: '放款量（'+ nowMoney +'元）  今日（'+ todayMoney +'元）  总金额（'+ allMoney +'元）',
					}
				})
			})
			
			//第一个图 默认一年放款量折线图,area regexp '贵州省'
			$.getJSON("/statis/getStatisByDate",{tab:"bargain_loan",param:"loanAmount,itemType",datePara:"date",filter:"progress=4#progress<6"},function(data){
				var names = "",
					loanAmountArr = [],
					allloanAmount = 0,
					$fkChartBox = $(fkChartBox),
					todayMoney = $fkChartBox.data("today"),
					allMoney = $fkChartBox.data("all");
				if(data.code == 1){
					names = data.names;
					loanAmountArr = data.data.loanAmount.sum;
					allloanAmount = 0;

					for(var i = 0;i < loanAmountArr.length;i++){
						allloanAmount += loanAmountArr[i];
					}
					$fkChartBox.data("now",allloanAmount);
					todayMoney = loanAmountArr[loanAmountArr.length - 1];
					$fkChartBox.data("today",todayMoney);
				}
				fkChart.setOption({
					title: {
				        text: '放款量（'+ allloanAmount +'元）  今日（'+ todayMoney +'元）  总金额（'+ allMoney +'元）',
				        subtext: (year - 1) +"-"+ year,
				        textStyle: {
				       		fontWeight: 'normal',
				       		color: '#666'
				        }
					},
					color:["#09F"],
					tooltip: {
				        trigger: 'axis'
				    },
				    legend: {
				        data:['放款量']
				    },
				    grid: {
				        left: '0',
				        right: '1.6%',
				        bottom: '0',
				        containLabel: true
				    },
				    toolbox: {
				        show : true,
				        feature : {
				            dataView : {show: true, readOnly: false},
				            magicType : {show: true, type: ['line', 'bar']},
				            restore : {show: true},
				            saveAsImage : {show: true}
				        }
				    },
				    xAxis: [
				    	{
					        type: 'category',
					        data: data.names
					    }
				    ],
				    yAxis: {
				        type: 'value'
				    },
				    series: [
				        {
				            name:'放款量',
				            type:'line',
				            data:loanAmountArr
				        }
				    ]
				})
				
			})
			
			//产品类型饼图
			$.getJSON("/statis/getStatis",{tab:"bargain_loan",param:"itemType"},function(data){
				var itemType = [],
					itemTypeTitle = ['车抵贷12期','车抵贷18期'],
					formatterTitle = ['车抵贷12期','车抵贷18期'];
				if(data.code == 1){
					itemType = data.itemType;
					itemTypeTitle = [];
					formatterTitle = [];
					for(var i = 0;i < itemType.length;i++){
						itemTypeTitle.push(itemType[i].name)
						formatterTitle.push("456" + i)
					}
				}
				itemTypeChar.setOption({
					title : {
				        text: '产品类型',
				        x:'40%',
				        textStyle: {
				       		fontWeight: 'normal',
				       		color: '#666'
				        }
				    },
				    toolbox: {
				        show : true,
				        feature : {
				            dataView : {show: true, readOnly: false},
				            saveAsImage : {show: true}
				        }
				    },
				    color:["#337ab7","#5cb85c","#5bc0de","#f0ad4e"],
				    tooltip : {
				        trigger: 'item',
				        formatter: "{a} <br/>{b} : {c} ({d}%)"
				    },
				    legend: {
				        orient: 'vertical',
				        left: 'left',
				        data: itemTypeTitle,
				        normal:{ 
                            label:{ 
                               show: true, 
                               formatter: '{b} : {c} ({d}%)' 
                            }
                        }
				    },
				    series : [
				        {
				            name: '产品类型',
				            type: 'pie',
				            radius : '55%',
				            center: ['50%', '60%'],
				            data:itemType,
				            /*label: { 
				                normal: { 
				                    position: 'inner' //内置文本标签 
				                } 
				            },
				             */
				            itemStyle: {
				            	normal:{ 
	                                label:{ 
	                                   show: true, 
	                                   formatter: '{b} : {c} ({d}%)' 
	                                }, 
	                                labelLine :{show:true}
	                            },
				                emphasis: {
				                    shadowBlur: 10,
				                    shadowOffsetX: 0,
				                    shadowColor: 'rgba(0, 0, 0, 0.5)'
				                }
				            }
				        }
				    ]
				})
			})
			
			//统计通过率
			$.getJSON("/statis/getStatis",{tab:"bargain_loan",param:"progress"},function(data){
				var progress = [],
					newProgress = [];
				if(data.code == 1){
					progress = data.progress;
					for(var i = 0;i < progress.length;i++){
						var json = {};
						if(progress[i].name == 4){//已放款
							json.name = "已通过";
							json.value = progress[i].value;
						}else if(progress[i].name == 6){//已拒绝、放弃
							json.name = "未通过";
							json.value = progress[i].value;
						}
						newProgress.push(json);
					}
				}
				
				orderChar.setOption({
					title : {
				        text: '通过率',
				        x:'42%',
				        textStyle: {
				       		fontWeight: 'normal',
				       		color: '#666'
				        }
				    },
				    color:["#337ab7","#5cb85c"],
				    toolbox: {
				        show : true,
				        feature : {
				            dataView : {show: true, readOnly: false},
				            saveAsImage : {show: true}
				        }
				    },
				    tooltip : {
				        trigger: 'item',
				        formatter: "{a} <br/>{b} : {c} ({d}%)"
				    },
				    legend: {
				        orient: 'vertical',
				        left: 'left',
				        data: ['已通过','未通过']
				    },
				    series : [
				        {
				            name: '通过率',
				            type: 'pie',
				            radius : '55%',
				            center: ['50%', '60%'],
				            data:newProgress,
				            itemStyle: {
				            	normal:{ 
	                                label:{ 
	                                   show: true, 
	                                   formatter: '{b} : {c} ({d}%)' 
	                                }, 
	                                labelLine :{show:true}
	                            },
				                emphasis: {
				                    shadowBlur: 10,
				                    shadowOffsetX: 0,
				                    shadowColor: 'rgba(0, 0, 0, 0.5)'
				                }
				            }
				        }
				    ]
				})
			})
			
			$.getJSON("/statis/getStatisByDate",{tab:"bargain_loan",param:"loanAmount,itemType,progress",datePara:"date"},function(data){
				var names = "",
					orderNum = [],//单量
					sucProgress = [];//放款单量
				if(data.code == 1){
					names = data.names;
					sucProgress = data.data.progress["4"];
					if(!sucProgress)sucProgress = [];
					orderNum = data.orderNum;
				}
				ywChar.setOption({
					title : {
				        text: '总业绩图',
				        subtext: (year - 1) +"-"+ year,
				        textStyle: {
				       		fontWeight: 'normal',
				       		color: '#666'
				        }
				    },
				    color:["#0099FF","#5cb85c"],
				    tooltip : {
				        trigger: 'axis'
				    },
				    legend: {
				        data:['总单量','放款量']
				    },
				    toolbox: {
				        show : true,
				        feature : {
				        	dataView : {show: true, readOnly: false},
				        	magicType : {show: true, type: ['line', 'bar']},
				            restore : {show: true},
				            saveAsImage : {show: true}
				        }
				    },
				    calculable : true,
				    xAxis : [
				        {
				            type : 'category',
				            data : data.names
				        }
				    ],
				    yAxis : [
				        {
				            type : 'value'
				        }
				    ],
				    grid: {
				        left: '0',
				        right: '2.8%',
				        bottom: '0',
				        containLabel: true
				    },
				    series : [
				        {
				            name:'总单量',
				            type:'bar',
				            data:orderNum,
				            markPoint : {
				                data : [
				                    {type : 'max', name: '最大值'},
				                    {type : 'min', name: '最小值'}
				                ]
				            },
				            markLine : {
				                data : [
				                    {type : 'average', name: '平均值'}
				                ]
				            }
				        },
				        {
				            name:'放款量',
				            type:'bar',
				            data:sucProgress,
				            markPoint : {
				            	data : [
				                    {type : 'max', name: '最大值'},
				                    {type : 'min', name: '最小值'}
				                ]
				            },
				            markLine : {
				                data : [
				                    {type : 'average', name : '平均值'}
				                ]
				            }
				        }
				        
				    ]
				})
			})
			
			var yearDom = $("#year"),
				monthDom = $("#month");
			yearDom.change(function(){
				repeatChartsBox();
			})	
			
			monthDom.change(function(){
				if(yearDom.val() != ""){
					repeatChartsBox();
				}
			})
			
			provinceDom.change(function(){
				var index = $(this).val(),
					citySel = "";
				cityDom.html("<option value=''>选择城市</option>")
				
				repeatChartsBox();
				
				if(index == "")return;
				for(var i = 0;i < cityArr[index].length;i++){
					citySel += "<option value='"+ i +"'>"+ cityArr[index][i] +"</option>";
				}
				cityDom.append(citySel);
			})
			
			cityDom.change(function(){
				repeatChartsBox();
			})
				
			//遍历所有统计图
			function repeatChartsBox(){
				var year = yearDom.val(),
					month = monthDom.val();
					date = year +"-"+ month,
					provinceIndex = provinceDom.val(),
					cityIndex = cityDom.val(),
					area = "";
				
				if(year == ""){
					date = "";
				}else{
					if(month == "")date = year;
				}
				
				if(provinceIndex != ""){
					area = "area regexp '" + provinceArr[provinceIndex] + "'";
					if(cityIndex != ""){
						area = "area='" + provinceArr[provinceIndex] +","+ cityArr[provinceIndex][cityIndex] + "'";
					}
				}
				
				contariner.find(".change").each(function(){
					var that = $(this),
						filter = that.data("filter");
					if(filter == ""){
						filter = area;
					}else{
						filter = filter;
						if(area != ""){
							filter = filter +"#"+ area;
						}
					}
					
					if(that.hasClass("fkchart")){
						changeFkChart(date,filter);
					}else if(that.hasClass("ywchart")){
						changeYwChar(date,filter);
					}else if(that.hasClass("itemtypechart")){
						changeItemTypeChar(date,filter);
					}else if(that.hasClass("orderchar")){
						changeOrderChar(date,filter)
					}else if(that.hasClass("paymentchart")){
						changepaymentChar(date,filter)
					}
				})
			}
			
			//查询放款量统计图
			function changeFkChart(date,filter){
				var sendData = {
					tab:"bargain_loan",
					param:"loanAmount,itemType,progress",
					datePara:"date",
					dateRage:date,
					filter:filter
				}
				if(date == ""){
					delete sendData["dateRage"];
				}
				$.getJSON("/statis/getStatisByDate",sendData,function(data){
					var names = "",
						fkChartTitle = "",
						yearSel = yearDom.val(),
						fkChartSubtext = yearSel,
						newNames = [],
						loanAmountArr = [],
						allloanAmount = 0,//当前放款金额
						$fkChartBox = $(fkChartBox),
						todayMoney = $fkChartBox.data("today"),
						allMoney = $fkChartBox.data("all");
					fkChartTitle = '放款量（'+ allloanAmount +'元）  今日（'+ todayMoney +'元）  总金额（'+ allMoney +'元）';
					if(data.code == 1){
						names = data.names;
						fkChartSubtext = names[0].substring(0,4);
						newNames = [];
						loanAmountArr = data.data.loanAmount.sum;
						allloanAmount = 0;
						if(date == ""){
							fkChartSubtext = (year - 1) +"-"+ year;
							newNames = names;
						}else{
							if(date.indexOf("-") == -1){
								newNames = monthArr;
							}else{
								for(var i = 0;i < names.length;i++){
									var name = names[i];
									newNames.push(name.substring(name.indexOf("-") + 1));
								}
							}
						}
						
						for(var i = 0;i < loanAmountArr.length;i++){
							allloanAmount += loanAmountArr[i];
						}
						$fkChartBox.data("now",allloanAmount);
						fkChartTitle = '放款量（'+ allloanAmount +'元）  今日（'+ todayMoney +'元）  总金额（'+ allMoney +'元）';
					}else{
						if(date.indexOf("-") == -1){
							newNames = monthArr;
							for(var i = 0;i < newNames.length;i++){
								loanAmountArr.push(0);
							}
						}else{
							var month = date.split("-")[1],
								dates = new Date(yearSel,month,0).getDate();
							for(var i = 1;i <= dates;i++){
								var day = i;
								if(day < 10) day = "0" + day;
								newNames.push(month +"-"+ day);
								loanAmountArr.push(0);
							}
						}
					}
					
					fkChart.setOption({
						title: {
					        text: fkChartTitle,
					        subtext: fkChartSubtext,
					        textStyle: {
					       		fontWeight: 'normal',
					       		color: '#666'
					        }
						},
						xAxis: {
					        type: 'category',
					        boundaryGap: false,
					        data: newNames
					    },
					    series: [
					        {
					            name:'放款量',
					            type:'line',
					            data:loanAmountArr
					        }
					    ]
					})
				})
			}
			
			//查询业务量统计图
			function changeYwChar(date,filter){
				var sendData = {
						tab:"bargain_loan",
						param:"loanAmount,itemType,progress",
						datePara:"date",
						dateRage:date,
						filter:filter
					}
				if(date == ""){
					delete sendData["dateRage"];
				}
				$.getJSON("/statis/getStatisByDate",sendData,function(data){
					var names = "",
						yearSel = yearDom.val(),
						newNames = [],
						subTit = yearSel,
						orderNum = [],//单量
						sucProgress = [];//放款单量
					if(data.code == 1){
						/* 业务量统计图 */
						names = data.names;
						newNames = [];
						sucProgress = data.data.progress["4"];
						if(!sucProgress)sucProgress = [];
						orderNum = data.orderNum;
						if(date == ""){
							subTit = (year - 1) +"-"+ year;
							newNames = names;
						}else{
							if(date.indexOf("-") == -1){
								newNames = monthArr;
							}else{
								for(var i = 0;i < names.length;i++){
									var name = names[i];
									newNames.push(name.substring(name.indexOf("-") + 1));
									if(sucProgress.length != names.length)sucProgress.push(0);
								}
							}
						}
					}else{
						if(date.indexOf("-") == -1){
							newNames = monthArr;
							for(var i = 0;i < newNames.length;i++){
								sucProgress.push(0);
								orderNum.push(0);
							}
						}else{
							var month = date.split("-")[1],
								dates = new Date(yearSel,month,0).getDate();
							for(var i = 1;i <= dates;i++){
								var day = i;
								if(day < 10) day = "0" + day;
								newNames.push(month +"-"+ day);
								sucProgress.push(0);
								orderNum.push(0);
							}
						}
					}
						
					ywChar.setOption({
						title : {
					        subtext: subTit,
					    },
					    xAxis : [
					        {
					            type : 'category',
					            data : newNames
					        }
					    ],
					    series : [
					        {
					            name:'总单量',
					            type:'bar',
					            data:orderNum,
					            markPoint : {
					                data : [
					                    {type : 'max', name: '最大值'},
					                    {type : 'min', name: '最小值'}
					                ]
					            },
					            markLine : {
					                data : [
					                    {type : 'average', name: '平均值'}
					                ]
					            }
					        },
					        {
					            name:'放款量',
					            type:'bar',
					            data:sucProgress,
					            markPoint : {
					            	data : [
					                    {type : 'max', name: '最大值'},
					                    {type : 'min', name: '最小值'}
					                ]
					            },
					            markLine : {
					                data : [
					                    {type : 'average', name : '平均值'}
					                ]
					            }
					        }
					    ]
					})
				})
			}
			
			//查询产品类型统计图
			function changeItemTypeChar(date,filter){
				var sendData = {
						tab:"bargain_loan",
						param:"itemType",
						datePara:"date",
						dateRage:date,
						filter:filter
					}
				if(date == ""){
					delete sendData["dateRage"];
				}
				$.getJSON("/statis/getStatisByDate",sendData,function(data){
					var itemType = null,
						newItemType = [],
						itemTypeTitle = ['车抵贷12期','车抵贷18期'];
					if(data.code == 1){
						itemType = data.data.itemType;
						itemTypeTitle = [];
						for(var key in itemType){
							itemTypeTitle.push(key);
							var json = {},
								count = 0;
							for(var i = 0;i < itemType[key].length;i++){
								count += itemType[key][i];
							}
							json.name = key;
							json.value = count;
							newItemType.push(json);
						}
					}
					itemTypeChar.setOption({
						series : [
					        {
					            name: '产品类型',
					            type: 'pie',
					            radius : '55%',
					            center: ['50%', '60%'],
					            data:newItemType,
					            itemStyle: {
					                emphasis: {
					                    shadowBlur: 10,
					                    shadowOffsetX: 0,
					                    shadowColor: 'rgba(0, 0, 0, 0.5)'
					                }
					            }
					        }
					    ],
					    legend: {
					        orient: 'vertical',
					        left: 'left',
					        data: itemTypeTitle
					    }
					})
				})
			}
			
			//查询通过、未通过统计图
			function changeOrderChar(date,filter){
				var sendData = {
						tab:"bargain_loan",
						param:"progress",
						datePara:"date",
						dateRage:date,
						filter:filter
					}
				if(date == ""){
					delete sendData["dateRage"];
				}
				$.getJSON("/statis/getStatisByDate",sendData,function(data){
					var progress = null,
						newProgress = [],
						orderCharTitle = ['已通过','未通过'];
					if(data.code == 1){
						progress = data.data.progress;
						orderCharTitle = [];
						for(var key in progress){
							var json = {},
								count = 0;
							for(var i = 0;i < progress[key].length;i++){
								count += progress[key][i];
							}
							var name = "";
							if(key == "4"){
								name = "已通过";
							}else if(key == "6"){
								name = "未通过";
							}
							orderCharTitle.push(name);
							json.name = name;
							json.value = count;
							newProgress.push(json);
						}
					}
					orderChar.setOption({
						series : [
					        {
					            name: '通过率',
					            type: 'pie',
					            radius : '55%',
					            center: ['50%', '60%'],
					            data:newProgress,
					            itemStyle: {
					                emphasis: {
					                    shadowBlur: 10,
					                    shadowOffsetX: 0,
					                    shadowColor: 'rgba(0, 0, 0, 0.5)'
					                }
					            }
					        }
					    ]
					})
				})
			}
			
			//还款人数
			function changepaymentChar(date,filter){
				var sendData = {
						tab:"bargain_loan",
						param:"repayDateOfDay",
						datePara:"date",
						dateRage:date,
						filter:filter
					}
				if(date == ""){
					delete sendData["dateRage"];
				}
				$.getJSON("/statis/getStatisByDate",sendData,function(data){
					var repayDateOfDay = null,
						repayDateOfDayArr = [],
						repayDateTitle = ["每月5号","每月15号","每月25号"];
					if(data.code == 1){
						repayDateOfDays = data.data.repayDateOfDay;
						for(var key in repayDateOfDays){
							var json = {},
								name = "",
								value = 0;
							if(key == 5){
								name = "每月5号";
							}else if(key == 15){
								name = "每月15号";
							}else if(key == 25){
								name = "每月25号";
							}
							
							for(var i = 0;i < repayDateOfDays[key].length;i++){
								value += repayDateOfDays[key][i];
							}
							json.name = name;
							json.value = value;
							repayDateOfDayArr.push(json);
						}
					}
					paymentChar.setOption({
						series : [
					        {
					            data:repayDateOfDayArr
					        }
					    ]
					})
				})
			}
			
			window.onresize = function () {
				fkChart.resize();
				itemTypeChar.resize();
				orderChar.resize();
				ywChar.resize();
				paymentChar.resize();
			}
		})			
	</script>
</body>
</html>